package com.express.service.Impl;

import com.express.dto.OrderOverviewDto;
import com.express.entity.Order;
import com.express.mapper.OrdersMapper;
import com.express.service.IOrdersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.express.utils.BaseContext;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 
 * @since 2025-01-25
 */
@Service
public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Order> implements IOrdersService {

    @Autowired
    private OrdersMapper ordersMapper;

    /**
     * 获取订单概览
     *
     * @return
     */
    @Override
    public OrderOverviewDto getOrderOverview() {
        Long userId = BaseContext.getCurrentId();
        Order order = ordersMapper.selectById(userId);
        OrderOverviewDto orderOverviewDto = new OrderOverviewDto();
        BeanUtils.copyProperties(order, orderOverviewDto);
        return orderOverviewDto;
    }

}
